from ronglian_sms_sdk import SmsSDK
from celery import Celery

accId = '8a216da881ad9754018219bdebae19d9'
accToken = '47468758c17e46a9973732e824daaafe'
appId = '8a216da881ad9754018219bdecd019e0'


def send_sms_code(phone,data):
    sdk = SmsSDK(accId, accToken, appId)
    # 短信的模板
    tid = '1'
    mobile = phone
    datas = (data,)
    resp = sdk.sendMessage(tid, mobile, datas)
    return resp

# 创建celery对象
celery = Celery('my_celery',backend='redis://root@localhost:6379/4')


# task装饰器，用来生成任务的
@celery.task()
def send_sms_code_test():
    print("测试任务")

# 使用celery步騶
# 1.创建celery对象
# 2.定义任务
# 3.有存放结果的地方
# 4.定义配置文件，存放任务队列
# 5.执行异步任务：。delay()

from rest_framework.pagination import PageNumberPagination
class MyPagination(PageNumberPagination):
    page_size = 3  # 每页数量
    max_page_size = 5  # 每页最大的数量  以访特殊情况写不写都行
    page_size_query_param = 'size'  # 每页数量的参数名  供前端使用的
    page_query_param = 'page'  # 页码的参数名2